package com.ex.mzwqz.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.ex.mzwqz.R;

/**
 * Created by xiaguoqiang on 16/10/19.
 */
public abstract class BaseFragment extends Fragment{

    private View rootView;
    private String title;

    protected abstract int setContentViewResId();

    protected abstract void initView();

    protected abstract void initData();

    protected abstract void initEvent();


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        rootView = inflater.inflate(setContentViewResId(), container, false);
        View vTitle = rootView.findViewById(R.id.header_title);
        if(vTitle != null)
            ((TextView)vTitle).setText(title);
        initView();
        return rootView;
    }

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        initData();
        initEvent();
    }

    public View findViewById(int id){
        return rootView.findViewById(id);
    }

    public void onResume() {
        super.onResume();
    }

    public void onPause() {
        super.onPause();
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }
}
